package com.example.controller;

import com.example.mysql.model.User;
import com.example.mysql.persist.mapper.generated.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.net.URI;

/**
 * @Description: 测试
 * @Author: ZYX
 * @Date: 2021/11/1 10:28
 * @Version: 1.0
 */
@RestController
@RequestMapping("/mysql")
public class MysqlController {

    @Autowired
    private UserMapper userMapper;

    @PostMapping("/adduser")
    public String addUser(@RequestBody User user){
        userMapper.insert(user);
        return "success";
    }

    @RequestMapping(value = "/getUser/{id}",method = RequestMethod.GET)
    public User getUser(@PathVariable Long id){
        User user = userMapper.selectByPrimaryKey(id);
        return user;
    }

}
